package com.wondertek.poms.dao.po;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;

import javax.persistence.*;
import java.io.Serializable;

@Data
@Entity
@Table(name = "DISPLAY_FILE")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DisplayFile implements Serializable {

    private static final long serialVersionUID = -7730847135520177594L;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "DISPLAY_FILE_SEQ")
    @SequenceGenerator(name = "DISPLAY_FILE_SEQ", allocationSize = 1, sequenceName = "DISPLAY_FILE_SEQ")
    private Long id;

    /**内容ID*/
    @Column(name = "CONTENT_ID")
    private String contentId;

    /**图片ID*/
    @Column(name = "DP_FILE_ID")
    private String dpFileId;

    /**图片名称*/
    @Column(name = "DP_FILE_NAME")
    private String dpFileName;

    /**图片描述*/
    @Column(name = "DP_FILE_DETAIL")
    private String dpFileDetail;

    /**图片类型；01-GIF、02-BMP、03-JPG*/
    @Column(name = "DP_FILE_TYPE")
    private String dpFileType;

    /**类型编号*/
    @Column(name = "DP_USAGE_CODE")
    private String dpUsageCode;

    /**类型 00-图标01-图文*/
    @Column(name = "DP_USE_TYPE")
    private String dpUseType;

    /**适配类型*/
    @Column(name = "DP_ADAP_TYPE")
    private String dpAdapType;

    /**分辨率*/
    @Column(name = "DP_PIXEL")
    private String dpPixel;

    /**文件相对路径*/
    @Column(name = "DP_FILE_PATH")
    private String dpFilePath;

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result
                + ((contentId == null) ? 0 : contentId.hashCode());
        result = prime * result
                + ((dpAdapType == null) ? 0 : dpAdapType.hashCode());
        result = prime * result
                + ((dpFileDetail == null) ? 0 : dpFileDetail.hashCode());
        result = prime * result
                + ((dpFileId == null) ? 0 : dpFileId.hashCode());
        result = prime * result
                + ((dpFileName == null) ? 0 : dpFileName.hashCode());
        result = prime * result
                + ((dpFilePath == null) ? 0 : dpFilePath.hashCode());
        result = prime * result
                + ((dpFileType == null) ? 0 : dpFileType.hashCode());
        result = prime * result + ((dpPixel == null) ? 0 : dpPixel.hashCode());
        result = prime * result
                + ((dpUsageCode == null) ? 0 : dpUsageCode.hashCode());
        result = prime * result
                + ((dpUseType == null) ? 0 : dpUseType.hashCode());
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        return result;
    }
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        DisplayFile other = (DisplayFile) obj;
        if (contentId == null) {
            if (other.contentId != null)
                return false;
        } else if (!contentId.equals(other.contentId))
            return false;
        if (dpAdapType == null) {
            if (other.dpAdapType != null)
                return false;
        } else if (!dpAdapType.equals(other.dpAdapType))
            return false;
        if (dpFileDetail == null) {
            if (other.dpFileDetail != null)
                return false;
        } else if (!dpFileDetail.equals(other.dpFileDetail))
            return false;
        if (dpFileId == null) {
            if (other.dpFileId != null)
                return false;
        } else if (!dpFileId.equals(other.dpFileId))
            return false;
        if (dpFileName == null) {
            if (other.dpFileName != null)
                return false;
        } else if (!dpFileName.equals(other.dpFileName))
            return false;
        if (dpFilePath == null) {
            if (other.dpFilePath != null)
                return false;
        } else if (!dpFilePath.equals(other.dpFilePath))
            return false;
        if (dpFileType == null) {
            if (other.dpFileType != null)
                return false;
        } else if (!dpFileType.equals(other.dpFileType))
            return false;
        if (dpPixel == null) {
            if (other.dpPixel != null)
                return false;
        } else if (!dpPixel.equals(other.dpPixel))
            return false;
        if (dpUsageCode == null) {
            if (other.dpUsageCode != null)
                return false;
        } else if (!dpUsageCode.equals(other.dpUsageCode))
            return false;
        if (dpUseType == null) {
            if (other.dpUseType != null)
                return false;
        } else if (!dpUseType.equals(other.dpUseType))
            return false;
        if (id == null) {
            if (other.id != null)
                return false;
        } else if (!id.equals(other.id))
            return false;
        return true;
    }
    @Override
    public String toString() {
        return "ImageFile [id=" + id + ", contentId=" + contentId
                + ", dpFileId=" + dpFileId + ", dpFileName=" + dpFileName
                + ", dpFileDetail=" + dpFileDetail + ", dpFileType="
                + dpFileType + ", dpUsageCode=" + dpUsageCode + ", dpUseType="
                + dpUseType + ", dpAdapType=" + dpAdapType + ", dpPixel="
                + dpPixel + ", dpFilePath=" + dpFilePath + "]";
    }
}
